package com.ostrich.a2104gao5

/**
 * @Author : yaotianxue
 * @Time : On 2023/10/13 10:07
 * @Description : Test1
 */
//3.编译时常量
val code = 101
fun main(){
//    int a = 10;
    //1.声明变量：var 可变变量 val 只读不可变变量
    var a:Int = 10
    a = 7

    val b:Int = 8
//    b = 7
    //2.类型推断
    var c = 11
    var str = "123456"

    //4.if 语句
    if(str == "123456"){
        println("符合条件")
    }else{
        println("不符合条件")
    }
    //5.range表达式
    if(c in 11..13){
        println("符合条件")
    }else{
        println("不符合条件")
    }
    //6.when表达式：代替switch
    val school = "5学"
    val level = when (school){
        "0学" -> "学前班"
        "1学" -> "少儿"
        "2学" -> "青年"
        else -> "不知道"
    }
    println(level)

    //7.String 模板
    val str1 = "如花"
    val str2 = "似玉"
    println("$str1 love $str2")

    val flag = true
    println("你可以吗? ${if(flag) "我可以" else "不可以" }")
    //8.函数调用
    val doSomeThing = doSomeThing(10, "张三")
    println(doSomeThing)
    //默认参数
    val doSomeThing1 = doSomeThing(name = "李四")
    println(doSomeThing1)

}
//8.函数声明
private fun  doSomeThing(age:Int = 2,name:String):String{
    return "名字叫$name 年龄$age"
}